home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / mx / managers / PopUpManager.as < prev    next >
Text File  |  2007-11-08  |  5KB  |  149 lines

  1. class mx.managers.PopUpManager
  2. {
  3.    static var version = "2.0.2.126";
  4.    static var mixins = undefined;
  5.    function PopUpManager()
  6.    {
  7.    }
  8.    static function createModalWindow(parent, o, broadcastOutsideEvents)
  9.    {
  10.       var _loc2_ = parent.createChildAtDepth("Modal",mx.managers.DepthManager.kTopmost);
  11.       _loc2_.setDepthBelow(o);
  12.       o.modalID = _loc2_._name;
  13.       _loc2_._alpha = _global.style.modalTransparency;
  14.       _loc2_.tabEnabled = false;
  15.       if(broadcastOutsideEvents)
  16.       {
  17.          _loc2_.onPress = mx.managers.PopUpManager.mixins.onPress;
  18.       }
  19.       else
  20.       {
  21.          _loc2_.onPress = mx.managers.PopUpManager.mixins.nullFunction;
  22.       }
  23.       _loc2_.onRelease = mx.managers.PopUpManager.mixins.nullFunction;
  24.       _loc2_.resize = mx.managers.PopUpManager.mixins.resize;
  25.       mx.managers.SystemManager.init();
  26.       mx.managers.SystemManager.addEventListener("resize",_loc2_);
  27.       _loc2_.resize();
  28.       _loc2_.useHandCursor = false;
  29.       _loc2_.popUp = o;
  30.       o.modalWindow = _loc2_;
  31.       o.deletePopUp = mx.managers.PopUpManager.mixins.deletePopUp;
  32.       o.setVisible = mx.managers.PopUpManager.mixins.setVisible;
  33.       o.getVisible = mx.managers.PopUpManager.mixins.getVisible;
  34.       o.addProperty("visible",o.getVisible,o.setVisible);
  35.    }
  36.    static function createPopUp(parent, className, modal, initobj, broadcastOutsideEvents)
  37.    {
  38.       if(mx.managers.PopUpManager.mixins == undefined)
  39.       {
  40.          mx.managers.PopUpManager.mixins = new mx.managers.PopUpManager();
  41.       }
  42.       if(broadcastOutsideEvents == undefined)
  43.       {
  44.          broadcastOutsideEvents = false;
  45.       }
  46.       var _loc5_ = parent._root;
  47.       if(_loc5_ == undefined)
  48.       {
  49.          _loc5_ = _root;
  50.       }
  51.       while(parent != _loc5_)
  52.       {
  53.          parent = parent._parent;
  54.       }
  55.       initobj.popUp = true;
  56.       var _loc4_ = parent.createClassChildAtDepth(className,!(broadcastOutsideEvents || modal) ? mx.managers.DepthManager.kTop : mx.managers.DepthManager.kTopmost,initobj);
  57.       var _loc2_ = _root;
  58.       var _loc6_ = _loc2_.focusManager != undefined;
  59.       while(_loc2_._parent != undefined)
  60.       {
  61.          _loc2_ = _loc2_._parent._root;
  62.          if(_loc2_.focusManager != undefined)
  63.          {
  64.             _loc6_ = true;
  65.             break;
  66.          }
  67.       }
  68.       if(_loc6_)
  69.       {
  70.          _loc4_.createObject("FocusManager","focusManager",-1);
  71.          if(_loc4_._visible == false)
  72.          {
  73.             mx.managers.SystemManager.deactivate(_loc4_);
  74.          }
  75.       }
  76.       if(modal)
  77.       {
  78.          mx.managers.PopUpManager.createModalWindow(parent,_loc4_,broadcastOutsideEvents);
  79.       }
  80.       else
  81.       {
  82.          if(broadcastOutsideEvents)
  83.          {
  84.             _loc4_.mouseListener = new Object();
  85.             _loc4_.mouseListener.owner = _loc4_;
  86.             _loc4_.mouseListener.onMouseDown = mx.managers.PopUpManager.mixins.onMouseDown;
  87.             Mouse.addListener(_loc4_.mouseListener);
  88.          }
  89.          _loc4_.deletePopUp = mx.managers.PopUpManager.mixins.deletePopUp;
  90.       }
  91.       return _loc4_;
  92.    }
  93.    function onPress(Void)
  94.    {
  95.       var _loc3_ = this.popUp._root;
  96.       if(_loc3_ == undefined)
  97.       {
  98.          _loc3_ = _root;
  99.       }
  100.       if(this.popUp.hitTest(_loc3_._xmouse,_loc3_._ymouse,false))
  101.       {
  102.          return undefined;
  103.       }
  104.       this.popUp.dispatchEvent({type:"mouseDownOutside"});
  105.    }
  106.    function nullFunction(Void)
  107.    {
  108.    }
  109.    function resize(Void)
  110.    {
  111.       var _loc2_ = mx.managers.SystemManager.__get__screen();
  112.       this.setSize(_loc2_.width,_loc2_.height);
  113.       this.move(_loc2_.x,_loc2_.y);
  114.    }
  115.    function deletePopUp(Void)
  116.    {
  117.       if(this.modalWindow != undefined)
  118.       {
  119.          this._parent.destroyObject(this.modalWindow._name);
  120.       }
  121.       this._parent.destroyObject(this._name);
  122.    }
  123.    function setVisible(v, noEvent)
  124.    {
  125.       super.setVisible(v,noEvent);
  126.       this.modalWindow._visible = v;
  127.    }
  128.    function getVisible(Void)
  129.    {
  130.       return this._visible;
  131.    }
  132.    function onMouseDown(Void)
  133.    {
  134.       var _loc3_ = this.owner._root;
  135.       if(_loc3_ == undefined)
  136.       {
  137.          _loc3_ = _root;
  138.       }
  139.       var _loc4_ = new Object();
  140.       _loc4_.x = _loc3_._xmouse;
  141.       _loc4_.y = _loc3_._ymouse;
  142.       _loc3_.localToGlobal(_loc4_);
  143.       if(!this.owner.hitTest(_loc4_.x,_loc4_.y,false))
  144.       {
  145.          this.owner.mouseDownOutsideHandler(this.owner);
  146.       }
  147.    }
  148. }
  149.